#ifndef __Glove_structs_h__
#define __Glove_structs_h__

#include "gloveCommands.h"

namespace vkbrd
{
	struct BoolFingers
	{
		gInt fin;

		bool operator()(int _i) const
		{
			return (fin & (1 << _i));
		}
		void set(int _i, bool _val)
		{
			if (_val)
				fin |= (1<<_i);
			else
				fin &= (~(1<<_i));
		}

		BoolFingers shiftRightCopy(int _val) const
		{
			return BoolFingers(fin >> _val);
		}

		int flagsSetCount()
		{
			int count = 0;
			for (int i = 0; i < numGloves * fingerCount; ++i)
				if (this->operator()(i))
					++count;
			return count;
		}

		BoolFingers(){fin = 0;}

		BoolFingers(gInt _fingers){fin = _fingers;}
	};

	inline bool operator ==(const BoolFingers& _a, const BoolFingers& _b)
	{
		for (int i = 0; i < fingerCount; ++i)
			if (_a(i) != _b(i))
				return false;

		return true;
	}

	struct gIntFingers
	{
		gInt fin[fingerCount];

		gInt& operator[](int _i)
		{
			return (fin[_i]);
		}

		const gInt& operator[](int _i) const
		{
			return fin[_i];
		}

		gIntFingers()
		{
			for(int i=0; i < fingerCount; ++i) fin[i] = 0;
		}
	};

	inline gIntFingers& operator+=(gIntFingers& _a, const gIntFingers& _b)
	{
		for(int i = 0; i < fingerCount; ++i)
			_a.fin[i] += _b.fin[i];
		return _a;
	}

	inline gIntFingers& operator/(gIntFingers& _a, const int& _b)
	{
		for (int i = 0; i < fingerCount; ++i)
			_a.fin[i] /= _b;
		return _a;
	}

	struct MinMax
	{
		gInt minPress;
		gInt maxPress;
	};
} //namespace vkbrd
#endif	//__Glove_structs_h__